package net.togogo.controller;

import net.togogo.bean.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController    //组合注解  @ResponseBody与@Controller合写
public class JsonController {

    @RequestMapping("/json")
    public User getJson(){
        User user = new User();
        user.setId(1);
        user.setName("钱多多");
        user.setPassword("123456");
        user.setBirthday(new Date());
        return user;
    }

    @RequestMapping("jsons")
    public List<User> getJsons(){
        List<User> users = new ArrayList<>();
        User user = new User();
        user.setId(1);
        user.setName("钱多多");
        user.setPassword("123456");
        user.setBirthday(new Date());
        users.add(user);

        user = new User();
        user.setId(2);
        user.setName("钱多多2");
        user.setPassword("1234562222");
        user.setBirthday(new Date());
        users.add(user);

        return users;
    }
}
